package com.zejson.service.base;

import com.zejson.dao.GeneralDao;
import com.zejson.dao.inf.GeneralDaoInf;
import com.zejson.util.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BasicService{

    @Resource
    GeneralDaoInf generalDao;

    public void setGeneralDao(GeneralDaoInf generalDao) {
        this.generalDao = generalDao;
    }

    public GeneralDaoInf getGeneralDao() {
        return generalDao;
    }

    public Object getById(String mapper, int id) throws ClassNotFoundException {
        return generalDao.selectByPrimaryKey(mapper, id);
    }

    public int deleteById(String mapper, int id) throws ClassNotFoundException {
        return generalDao.deleteByPrimaryKey(mapper, id);
    }

    public int insert(String mapper, Object record) throws ClassNotFoundException {
        return generalDao.insert(mapper, record);
    }

    public int updateById(String mapper, Object record) throws ClassNotFoundException {
        return generalDao.updateByPrimaryKey(mapper, record);
    }


    public Page setPage(String mapper, Page page) throws ClassNotFoundException {
        getGeneralDao().setPage(mapper, page);
        return page;
    }

    public int insertByAutoGeneratePK(String mapper, Object record) throws ClassNotFoundException {
        return generalDao.insertByAutoGeneratePK(mapper, record);
    }
}
